cmake_minimum_required(VERSION 2.6)

set (LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}")

set (NTH_LIB_SOURCES   "${CMAKE_CURRENT_LIST_DIR}/lib.c")
set (NTH_LIB_LIBRARIES "gmp")

if (WIN32)
	set (NTH_LIB_SOURCES   ${NTH_LIB_SOURCES}   "${CMAKE_CURRENT_LIST_DIR}/lib-win32.c")
	set (NTH_LIB_LIBRARIES ${NTH_LIB_LIBRARIES} "kernel32")
elseif (UNIX)
	set (NTH_LIB_SOURCES   ${NTH_LIB_SOURCES}   "${CMAKE_CURRENT_LIST_DIR}/lib-unix.c")
	set (NTH_LIB_LIBRARIES ${NTH_LIB_LIBRARIES} "dl")
else()
	set (NTH_LIB_SOURCES   ${NTH_LIB_SOURCES}   "${CMAKE_CURRENT_LIST_DIR}/lib-unknown.c")
	set (NTH_LIB_LIBRARIES ${NTH_LIB_LIBRARIES} "")
endif()

add_library           (nth-lib SHARED ${NTH_LIB_SOURCES})
target_link_libraries (nth-lib ${NTH_LIB_LIBRARIES})

set (HEADER_INPUT_PATH  "${CMAKE_CURRENT_LIST_DIR}/nth-lib.h")
set (HEADER_OUTPUT_PATH "${PROJECT_BINARY_DIR}")

file(COPY "${HEADER_INPUT_PATH}" DESTINATION "${HEADER_OUTPUT_PATH}")

install(TARGETS "nth-lib"             DESTINATION "lib")
install(FILES  "${HEADER_INPUT_PATH}" DESTINATION "include")

